home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CChoreQuartet 1.0.1 / CSelfCancelableChore.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  1.3 KB  |  66 lines  |  [TEXT/KAHL]

  1. /*
  2.  * CSelfCancelableChore.c
  3.  *
  4.  * A chore that can cancel itself.
  5.  *
  6.  * Chores that subclass off of this class, instead of CChore, have
  7.  * one extra privilege and one extra responsibility.  The privilege
  8.  * is that they can call cancelSelf()--they don't have to be canceled
  9.  * from an outside source.  The responsibility is that they must
  10.  * check reallyPerform() at the start of every Perform() method, and
  11.  * immediately return without doing anything if it's FALSE.
  12.  *
  13.  * © Copyright 1992 by Jamie R. McCarthy.  All rights reserved.
  14.  * This code can be both distributed and used freely.
  15.  * Internet: k044477@kzoo.edu            AppleLink: j.mccarthy
  16.  *
  17.  */
  18.  
  19.  
  20.  
  21. /********************************/
  22.  
  23. #include "CSelfCancelableChore.h"
  24.  
  25. /********************************/
  26.  
  27. #include "CCancelerChore.h"
  28.  
  29. /********************************/
  30.  
  31.  
  32.  
  33. void CSelfCancelableChore::cancelSelf(void)
  34. {
  35.     hasBeenCancelled = TRUE;
  36.     
  37.     if (!isUrgent) {
  38.         CCancelerChore *myCanceler;
  39.         myCanceler = new(CCancelerChore);
  40.         myCanceler->setCancelee(this);
  41.         gApplication->AssignUrgentChore(myCanceler);
  42.     }
  43. }
  44.  
  45.  
  46.  
  47. Boolean CSelfCancelableChore::reallyPerform(void)
  48. {
  49.     return !hasBeenCancelled;
  50. }
  51.  
  52.  
  53.  
  54. void CSelfCancelableChore::setUrgent(Boolean theUrgent)
  55. {
  56.     isUrgent = (theUrgent != FALSE);
  57. }
  58.  
  59.  
  60.  
  61. Boolean CSelfCancelableChore::getUrgent(void)
  62. {
  63.     return isUrgent;
  64. }
  65.  
  66.